# coding=utf-8
"""
    @Author：SimpleTree
    @date：2025/6/9 21:35
    @desc: 
"""
from drf_yasg import openapi
from rest_framework import serializers

from common.mixins.api_mixin import ApiMixin
from common.util.field_message import ErrMessage
from django.utils.translation import gettext_lazy as _


class DocumentSerializers(ApiMixin, serializers.Serializer):
    pass


class DocumentInstanceSerializer(ApiMixin, serializers.Serializer):
    name = serializers.CharField(required=True,
                                 error_messages=ErrMessage.char(_("document name")),
                                 max_length=128, min_length=1)
    paragraphs = ParagraphInstanceSerializer(required=False, many=True, allow_null=True)

    @staticmethod
    def get_request_body_api():
        return openapi.Schema(
            type=openapi.TYPE_OBJECT,
            required=['name', 'paragraphs'],
            properties={
                'name': openapi.Schema(type=openapi.TYPE_STRING, title=_('document name'),
                                       description=_('document name')),
                'paragraphs': openapi.Schema(type=openapi.TYPE_ARRAY, title=_('paragraphs'),
                                             description=_('paragraphs'),
                                             items=ParagraphSerializers.Create.get_request_body_api())
            }
        )